package com.jpxx.netty.socket;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.net.InetAddress;
import java.net.ServerSocket;
import java.net.Socket;
import java.net.UnknownHostException;

public class Client {
	 public static void main(String[] args) throws Exception {
		 	//1.创建客户端Socket，指定服务器地址和端口
	        Socket socket = new Socket("192.168.85.1",9998);
	        //2.获取输出流，向服务器端发送信息
	        OutputStream os = socket.getOutputStream();//字节输出流
	        PrintWriter printWriter = new PrintWriter(os);//将输出流包装为打印流
	        //获取客户端的IP地址
	        InetAddress address = InetAddress.getLocalHost();
	        String ip = address.getHostAddress();
	        printWriter.write("~Hi sever 我是客户端！！ip:"+ip);
	        printWriter.flush();
	        socket.shutdownOutput();//关闭输出流
	        socket.close();
		 

             
	}
}
